"""
创建一个主类为: Person
  __name,__age,address
创建一个子类为: Student，继承Person
  school,courseList,gpa
创建一个子类为: Teacher，继承Person
  school,title

每一个类都有display方法：输出为
名字： 年龄： 地址：
"""


# 面向对象当中：封装思想
# 仅限于类使用的私有成员
# 在Python中，实现类的私有有两种变量的前缀：_ __
# get set方法以设置类中的私有成员
# Final：将类或者变量设置为常量，不可变的
# 在class前@Final表示类不可变；a: Final = 1，表示a为常量

# 前向声明：为了更好地阅读代码，实现更好的封装效果
def newPerson(name, age, address):
    Person(name, age, address)


def newTeacher(name, age, address, school, title):
    Teacher(name, age, address, school, title)


def newStudent(name, age, address, school, courseList, gpa):
    Student(name, age, address, school, courseList, gpa)


def newTutor(name, age, address, sSchool, eSchool, title, courseList, gpa):
    Tutor(name, age, address, sSchool, eSchool, title, courseList, gpa)


class Person:
    __name = ""
    __age = 0
    __address = ""

    def __init__(self, name, age, address):
        self.__name = name
        self.__age = age
        self.__address = address

    def getName(self):
        name = self.__name
        return name

    def display(self):
        print(f"名字：{self.__name}, 年龄:{self.__age}, 地址:{self.__address}")


class Student(Person):
    school = ""
    courseList = []
    gpa = 0.0

    def __init__(self, name, age, address, school, courseList, gpa):
        Person.__init__(self, name, age, address)
        self.school = school
        self.courseList = courseList
        self.gpa = gpa

    def display(self):
        Person.display(self)
        print(f"学校：{self.school}, 课程：{self.courseList}, 成绩:{self.gpa}")


class Teacher(Person):
    school = ""
    title = ""

    # __name = ""

    def __init__(self, name, age, address, school, title):
        Person.__init__(self, name, age, address)
        self.name = name
        self.school = school
        self.title = title

    def display(self):
        Person.display(self)
        print(f"学校：{self.school}, 职称:{self.title}")


# 创建一个助教类，同时继承来自于Student和Teacher
class Tutor(Student, Teacher):
    sSchool = ""
    eSchool = ""

    def __init__(self, name, age, address, sSchool, eSchool, title, courseList, gpa):
        Student.__init__(self, name, age, address, sSchool, courseList, gpa)
        self.eSchool = eSchool
        self.title = title

    def display(self):
        print("作为学生的信息如下：")
        Student.display(self)
        print("作为老师的信息如下：")
        Teacher.display(self)


if __name__ == '__main__':
    # 学生：小张
    sCourseList = ["数学", "英语"]
    xiaozhang = Student("小张", 18, "上海", "清华", sCourseList, 3.8)
    xiaozhang.display()

    # 老师：张老
    zhanglao = Teacher("张老", 50, "北京", "北大", "职称")
    zhanglao.display()

    # 助教：老张
    laozhang = Tutor("老张", 30, "广州", "清华", "北大", "助教", sCourseList, 4.0)
    laozhang.display()

    # 人：张三
    zhangsan = Person("张三", 7, "深圳")
    print(zhangsan.getName())